<%-- 
    Document   : uploaddoc
    Created on : Mar 9, 2012, 11:03:59 AM
    Author     : kasun
--%>
<%@page import="java.util.List"%>
<%@page import="java.util.Iterator"%>
<%@page import="java.util.ArrayList"%>
<%@page import="org.w3c.dom.Document"%>
    <%@ page import="java.sql.*"%>

<%@ page import="java.io.*"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@page import="karshafinsearch.parseDocument"%>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script language="javascript">
    function uploaddoc()
    {
        //TODo need to implement saving functinlity
        
        
        
        var MESSAGE = "file Uploaded succes fully ";
        var user = "username";
        var SECONDS = 5;


        document.getElementById("msg").innerHTML = MESSAGE;
        document.getElementById("uploaduser").innerHTML = user ;
        //window.setInterval("blankMessage()", SECONDS * 1000);


        // document.write("text");
 
    }
</script>



<div id="indexRightColumn">


    <h2>Upload to Document Collection</h2> 
    


<%

Connection con=null;

ResultSet rs=null;

PreparedStatement psmt=null;

FileInputStream fis;

String url="jdbc:mysql://localhost:3306/karshamarkuptool";

try{

Class.forName("com.mysql.jdbc.Driver").newInstance();

con=DriverManager.getConnection(url,"root","nbuser");

File image=new File("F:/karsha project/Agreements/pdf version/creditcardagreement_263.PDF");

psmt = con.prepareStatement("insert into document(Name,DocFile,UserID, CollectionID ) values(?,?,?,?)");
//fis = new FileInputStream(f);
psmt.setString(1, "name");
//psmnt.setBinaryStream(2, (InputStream)fis, (int)(f.length()));
psmt.setInt(3, 1);
psmt.setInt(4, 1);



fis=new FileInputStream(image);

psmt.setBinaryStream(2, (InputStream)fis, (int)(image.length()));

int s = psmt.executeUpdate();

if(s>0) {

%>

<b><font color="Blue">

<% out.println("Image Uploaded successfully !"); %>

</font></b>

<%

}

else {

out.println("unsucessfull to upload image.");

}

con.close();

psmt.close();

}catch(Exception ex){

out.println("Error in connection : "+ex);

}

%>
    
    
    
    
<!--    <FORM ENCTYPE="multipart/form-data" ACTION="upload" METHOD=POST>
<br><br><br>
<center><table border="2" >
<tr><center><td colspan="2"><p align="center"><B>UPLOAD THE FILE</B><center></td></tr>
<tr><td><b>Choose the file To Upload:</b>
</td>
<td><INPUT NAME="file" TYPE="file"></td></tr>
<tr><td colspan="2">
<p align="right"><INPUT TYPE="submit" VALUE="Send File" ></p></td></tr>
<table>
</center>
</FORM>-->
    
<!--    <div class="phraseBox3">
        <form name="uploaddoc" action="topkphrases">

        <div class="fileUpload">

                Document Name* <input type="text" name="docName" value="" lable="*Document Name" /><br><br>
                Select Collection* <select name="collection">
                    <option>Fixed Deposit</option>
                    <option>Credit Card</option>
                </select><br><br>
                <input type="file" name="docfile" value="filename" id="uploadfield"/> 
                <c:set var="filename" value="filename"/>


                    <input type="submit" value="Upload" name="upload"  /> 
                    <div class="metadata">
                        <div id="msg"></div>
                        <div id="uploaduser"></div>
                        <div id="datetime"></div>
                    </div>


           
            </form>
        </div>

    </div>   -->


</div>

